<template>
  <el-dialog
    title="修改隧道信息"
    :visible.sync="dialogEditorVisible"
    width="30%"
    :before-close="handleClose"
  >
    <el-form
      :inline="true"
      class="demo-form-inline"
      ref="form"
      :model="currentRow"
      label-width="100px"
    >
      <el-form-item label="预警类型">
        <el-select v-model="currentRow.warnType" placeholder="请选择">
          <el-option value="1" label="拱顶"></el-option>
          <el-option value="2" label="拱脚"></el-option>
          <el-option value="3" label="周边"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="预警值">
        <el-input v-model="currentRow.warnValue"></el-input>
      </el-form-item>
      <el-form-item label="创建时间">
        <el-input v-model="currentRow.createTime"></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="dialogEditorVisible = false">取 消</el-button>
      <el-button type="primary" @click="create">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import api from '../../../api'
import qs from 'qs'

export default {
  data() {
    return {
      dialogEditorVisible: false,
      eTypeList: [],
      tunnelList: [],
      fileList: [],
      currentRow: {}
    }
  },
  mounted() {
    this.$bus.$on('onShowSyswarnEditor', (row) => {
      this.dialogEditorVisible = true
      this.currentRow = row.rowdata
    })
  },
  methods: {
    handleClose(done) {
      this.$confirm('确认关闭？')
        .then((_) => {
          done()
        })
        .catch((_) => {})
    },
    create() {
      api
        .sysWarnupdate(qs.stringify(this.currentRow))
        .then((res) => {
          if (res.data.code == 2001) {
            this.$message({
              type: 'success',
              message: '更新成功!'
            })
            this.dialogEditorVisible = false
            this.$bus.$emit('onRefreshSyswarn')
          } else {
            this.$message({
              type: 'fail',
              message: '更新失败!'
            })
            this.dialogVisible = false
            console.log(res)
          }
        })
        .catch((err) => {})
    },
    onSubmit() {
      console.log('submit!')
    }
  }
}
</script>

<style scoped>
.avatar-uploader .el-upload {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  width: 50px !important;
  height: 50px !important;
  font-size: 28px;
  line-height: 50px !important;
  color: #8c939d;
  text-align: center;
}
.avatar {
  display: block;
  width: 50px !important;
  height: 50px !important;
}
.imgbeforepad {
  padding-top: 0px !important;
}
.avatar-uploader .el-icon-plus {
  margin: 15px !important;
}
</style>